#include <iostream>
#include <stdlib.h>
#include <ctime>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <cstring>
#include <string>
#include <stdio.h>
#include <unistd.h>
#include "Frame.h"
using namespace std;

int main()
{
    pid_t p1;
    int stat_val;

    Frame test = Frame(0, 1, 1, "crap");
    int file_pipe[2];
    Frame* buffer;

    socketpair(AF_UNIX, SOCK_STREAM, 0, file_pipe);

    p1 = fork();

    if(p1 != 0)
    {
        //Parent
        read(file_pipe[1], buffer, sizeof(Frame));
        cout << "Size of buffer is " << sizeof(*buffer) << " Size of Frame is: " << sizeof(Frame) << endl;
        cout << buffer << endl;
        cout << ((Frame)buffer).getMessage() << endl;
    }
    else
    {
        write(file_pipe[0], &test, sizeof(Frame));
        exit(0);
    }

    return 0;
}
